﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace calculator
{
    public partial class formBool : Form
    {
        public formBool()
        {
            InitializeComponent();
        }

        private void btnEvaluate_Click(object sender, EventArgs e)
        {
            BooleanCalculator booleanCalculator = new BooleanCalculator();
            
            TruthTableHTMLWriteOut htmlWriteOut = new TruthTableHTMLWriteOut();
            ExpressionParser parser = new ExpressionParser(txbExpression.Text.ToUpper());
            if (!parser.basicCheck() || !parser.checkString())
                MessageBox.Show("Illegal Input", "Illegal Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
            else
                htmlWriteOut.printTable(booleanCalculator.calculate(txbExpression.Text.ToUpper()));

            System.Diagnostics.Process.Start("expression.html");
        }
    }
}
